Maximum Width of Binary Tree

Easy

Question

Given the root of a tree, return the maximum width of the tree.

Maximum Width of Binary Tree Example 1

Input: root = [1, 2, 3, None, None, 6]

Output: 2

If the root is at the 0th level, the maximum width of the tree is at the 1st level with 2 nodes.

Maximum Width of Binary Tree Example 2

Input: root = [1, 2, 3, 4, 5, None, None, 8]

Output: 2

If the root is at the 0th level, the tree has a maximum width of 2 nodes on the 1st or 2nd levels.

Clarify the problem

What are some questions you'd ask an interviewer?

Understand the problem

What is the maximum width of this tree? root = [1, 2, 3, 4, 5, 6, 7, 8]
1
2
3
4

Login or signup to save your code.

Notes